package com.example.supermarket.controller;


import com.example.supermarket.Result;
import com.example.supermarket.entity.Category;
import com.example.supermarket.entity.Department;
import com.example.supermarket.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hpp
 * @since 2021-10-26
 */
@RestController
@RequestMapping("/department")
public class DepartmentController {
    @Autowired
    DepartmentService departmentService;

    @GetMapping("")
    public Result<List<Department>> getDepList(){
        List<Department> list = departmentService.list();
        if (list.size() != 0) {
            return new Result<>(200,"ok",list);
        }
        return new Result<>(0,"error",null);
    }


}

